#pragma once

#include "ActionExecutionSpecification.h"

#include "Action.h"

namespace uml {

ActionExecutionSpecification::ActionExecutionSpecification(const QString& umlType)
    : ExecutionSpecification(umlType) {}

void ActionExecutionSpecification::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    ExecutionSpecification::fromJson(json, errorList);
    action_ = JsonSerializable::create<Action>(json.value("action"), errorList);

}

void ActionExecutionSpecification::toJson(QJsonObject& json) {
    ExecutionSpecification::toJson(json);
    if (action_) {
        QJsonObject action_json;
        action_->toJson(action_json);
        json.insert("action", action_json);
    }
}

/// <summary>
/// action getter
/// Action whose execution is occurring.
/// </summary>
shared_ptr<Action> ActionExecutionSpecification::action() const {
    return action_;
}

/// <summary>
/// action setter
/// Action whose execution is occurring.
/// </summary>
void ActionExecutionSpecification::setAction(shared_ptr<Action> value) {
    action_ = value;
}

} // namespace uml
